<!doctype html>


<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>Interval (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
  </script>

  <script src="static/js/doc.js">
  </script>

  <meta charset="utf8">
</head>

<body onload="prettyPrint()">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>





<div class="colmask rightmenu">
<div class="colleft">
    <div class="col1">
      <!-- Column 1 start -->

<div id="title">
        <span class="fn">date.Interval</span>
        <span>Extends</span>
        <span class="fn-name">
          <a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">
            Object</a>
        </span>
</div>

<div class="g-section g-tpl-75-25">
  <div class="g-unit g-first" id="description">
    Class representing a date/time interval. Used for date calculations.
<pre class="lang-js">
new goog.date.Interval(0, 1) // One month
new goog.date.Interval(0, 0, 3, 1) // Three days and one hour
new goog.date.Interval(goog.date.Interval.DAYS, 1) // One day
</pre>
  </div>


        <div class="g-unit" id="useful-links">
          <div class="title">Useful links</div>
          <ol>
            <li><a href="closure_goog_date_date.js.source.html"><span class='source-code-link'>Source Code</span></a></li>
          </ol>
        </div>
</div>






<h2 class="g-first">Inheritance</h2>
<pre class="inheritance">
Object
     <img src="static/images/inherit.gif">goog.date.Interval
</pre>




  <h2>Constructor</h2>
      <div class="fn-constructor">
    goog.date.Interval(<span><span class="arg">opt_years</span>,&nbsp;<span class="arg">opt_months</span>,&nbsp;<span class="arg">opt_days</span>,&nbsp;<span class="arg">opt_hours</span>,&nbsp;<span class="arg">opt_minutes</span>,&nbsp;<span class="arg">opt_seconds</span></span>)
  </div>

   <h3>Parameters</h3>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">opt_years</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span><span>&nbsp;|&nbsp;</span><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span></div>
        <div class="entryOverview">Years or string representing date part.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">opt_months</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span></div>
        <div class="entryOverview">Months or number of whatever date part specified by first parameter.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">opt_days</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span></div>
        <div class="entryOverview">Days.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">opt_hours</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span></div>
        <div class="entryOverview">Hours.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">opt_minutes</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span></div>
        <div class="entryOverview">Minutes.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">opt_seconds</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span></div>
        <div class="entryOverview">Seconds.</div>
     </td>
   </tr>
  </table>


<h2>Instance Methods</h2>


  <div class="legend">
        <span class="key publickey"></span><span>Public</span>
        <span class="key protectedkey"></span><span>Protected</span>
        <span class="key privatekey"></span><span>Private</span>
  </div>







<div>
       <div class="desc">
         Defined in
         <span class="fn-name">
            <a href="class_goog_date_Interval.html">
              goog.date.Interval
            </a>
         </span>
       </div>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.date.Interval.prototype.add"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">add<span class="args">(<span class="arg">interval</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Adds the Interval in the argument to this Interval field by field.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">interval</span>
        : <div class="fullType"><span class="type"><a href="class_goog_date_Interval.html">goog.date.Interval</a></span></div>
        <div class="entryOverview">The Interval to add.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_date_date.js.source.html#line647">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.date.Interval.prototype.clone"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">clone<span class="args">()</span>
        </span>
        &#8658; <div class="fullType"><span>!</span><span class="type"><a href="class_goog_date_Interval.html">goog.date.Interval</a></span></div>
      </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>


    <! -- Method details -->
    <div class="entryDetails">

   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span>!</span><span class="type"><a href="class_goog_date_Interval.html">goog.date.Interval</a></span></div>&nbsp;
            A clone of the interval object.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_date_date.js.source.html#line584">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.date.Interval.prototype.equals"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">equals<span class="args">(<span class="arg">other</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span></div>
      </div>


     <div class="entryOverview">
       Tests whether the given interval is equal to this interval.
Note, this is a simple field-by-field comparison, it doesn&#39;t
account for comparisons like &quot;12 months == 1 year&quot;.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">other</span>
        : <div class="fullType"><span class="type"><a href="class_goog_date_Interval.html">goog.date.Interval</a></span></div>
        <div class="entryOverview">The interval to test.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span></div>&nbsp;
            Whether the intervals are equal.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_date_date.js.source.html#line571">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.date.Interval.prototype.getInverse"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">getInverse<span class="args">()</span>
        </span>
        &#8658; <div class="fullType"><span>!</span><span class="type"><a href="class_goog_date_Interval.html">goog.date.Interval</a></span></div>
      </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>


    <! -- Method details -->
    <div class="entryDetails">

   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span>!</span><span class="type"><a href="class_goog_date_Interval.html">goog.date.Interval</a></span></div>&nbsp;
            Negative of this interval.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_date_date.js.source.html#line636">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.date.Interval.prototype.toIsoString"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">toIsoString<span class="args">(<span class="arg">opt_verbose</span>)</span>
        </span>
        &#8658; <div class="fullType"><span>?</span><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span></div>
      </div>


     <div class="entryOverview">
       Serializes goog.date.Interval into XML Schema duration (ISO 8601 extended).
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">opt_verbose</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span></div>
        <div class="entryOverview">Include zero fields in the duration string.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span>?</span><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span></div>&nbsp;
            An XML schema duration in ISO 8601 extended format, or null if the interval contains both positive and negative fields.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_date_date.js.source.html#line512">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
</div>














<h2>Static Methods</h2>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.date.Interval.fromIsoString"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.date.Interval.</span><span class="entryName">fromIsoString<span class="args">(<span class="arg">duration</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type"><a href="class_goog_date_Interval.html">goog.date.Interval</a></span></div>
      </div>


     <div class="entryOverview">
       Parses an XML Schema duration (ISO 8601 extended).
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">duration</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span></div>
        <div class="entryOverview">An XML schema duration in textual format. Recurring durations and weeks are not supported.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type"><a href="class_goog_date_Interval.html">goog.date.Interval</a></span></div>&nbsp;
            The duration as a goog.date.Interval or null if the parse fails.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_date_date.js.source.html#line478">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>



<h2>Static Properties</h2>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>





  <a name="goog.date.Interval.DAYS"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.date.Interval.</span><span class="entryName">DAYS</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span></div>
     </div>


     <div class="entryOverview">
       Days constant for the date parts.
     </div>

  </td>


  <td class="view-code">
     <a href="closure_goog_date_date.js.source.html#line609">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>





  <a name="goog.date.Interval.HOURS"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.date.Interval.</span><span class="entryName">HOURS</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span></div>
     </div>


     <div class="entryOverview">
       Hours constant for the date parts.
     </div>

  </td>


  <td class="view-code">
     <a href="closure_goog_date_date.js.source.html#line616">Code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>





  <a name="goog.date.Interval.MINUTES"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.date.Interval.</span><span class="entryName">MINUTES</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span></div>
     </div>


     <div class="entryOverview">
       Minutes constant for the date parts.
     </div>

  </td>


  <td class="view-code">
     <a href="closure_goog_date_date.js.source.html#line623">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>





  <a name="goog.date.Interval.MONTHS"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.date.Interval.</span><span class="entryName">MONTHS</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span></div>
     </div>


     <div class="entryOverview">
       Months constant for the date parts.
     </div>

  </td>


  <td class="view-code">
     <a href="closure_goog_date_date.js.source.html#line602">Code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>





  <a name="goog.date.Interval.SECONDS"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.date.Interval.</span><span class="entryName">SECONDS</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span></div>
     </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

  </td>


  <td class="view-code">
     <a href="closure_goog_date_date.js.source.html#line630">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>





  <a name="goog.date.Interval.YEARS"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.date.Interval.</span><span class="entryName">YEARS</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span></div>
     </div>


     <div class="entryOverview">
       Years constant for the date parts.
     </div>

  </td>


  <td class="view-code">
     <a href="closure_goog_date_date.js.source.html#line595">Code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
      <!-- Column 1 end -->
    </div>

        <div class="col2">
          <!-- Column 2 start -->
          <div class="col2-c">
            <h2 id="ref-head">Package date</h2>
            <div id="localView"></div>
          </div>

          <div class="col2-c">
            <h2 id="ref-head">Package Reference</h2>
            <div id="sideTypeIndex" rootPath="goog" current="date.Interval"></div>
          </div>
          <!-- Column 2 end -->
        </div>
</div>
</div>

</body>
</html>
